import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'backlogin',
      component: () => import('@/views/bcakend/backLogin.vue'),
      meta: { title: '后台登录' }
    },
    {
      path: '/home',
      name: 'admin',
      component: () => import('@/views/bcakend/backHome.vue'),
      meta: { title: '后台首页' },
      children: [
        {
          path: 'products',
          name: 'products',
          component: () => import('@/views/bcakend/product.vue'),
          meta: { title: '商品列表', requireAuth: true, role: 'admin' },
          
        },
        {
          path: 'add',
          name: 'add',
          component: () => import('@/views/bcakend/addproduct.vue'),
          meta: { title: '添加商品', requireAuth: true, role: 'admin' }
        },
        {
          path: 'emp',
          name: 'emp',
          component: () => import('@/views/bcakend/emp.vue'),
          meta: { title: '员工管理', requireAuth: true, role: 'admin' }
        },
        {
          path: 'orders',
          name: 'orders',
          component: () => import('@/views/bcakend/orders.vue'),
          meta: { title: '订单列表', requireAuth: true, role: 'admin' }
        },
        {
          path: 'orders/pending',
          name: 'pendingOrders',
          component: () => import('@/views/bcakend/pendingOrders.vue'),
          meta: { title: '待处理订单', requireAuth: true, role: 'admin' }
        },
        {
          path: 'orders/shipping',
          name: 'shippingOrders',
          component: () => import('@/views/bcakend/shippingOrders.vue'),
          meta: { title: '配送中订单', requireAuth: true, role: 'admin' }
        },
        {
          path: 'orders/completed',
          name: 'completedOrders',
          component: () => import('@/views/bcakend/completedOrders.vue'),
          meta: { title: '已完成订单', requireAuth: true, role: 'admin' }
        },
        {
          path: 'comments',
          name: 'comments',
          component: () => import('@/views/bcakend/comments.vue'),
          meta: { title: '商品评价管理', requireAuth: true, role: 'admin' }
        },
        // 添加文化资讯管理路由
        {
          path: 'cultural-info',
          name: 'culturalInfo',
          component: () => import('@/views/bcakend/culturalInfo.vue'),
          meta: { title: '文化资讯列表', requireAuth: true, role: 'admin' }
        },
        {
          path: 'add-cultural-info',
          name: 'addCulturalInfo',
          component: () => import('@/views/bcakend/addculturalinfo.vue'),
          meta: { title: '添加文化资讯', requireAuth: true, role: 'admin' }
        },
      ]
    },

    // 前台路由
    {
      path: '/museum',
      name: 'museum',
      component: () => import('@/views/font/Museum.vue'),
      meta: { title: '博物馆文创' },
    },
    // 添加全部商品路由
    {
      path: '/allproducts',
      name: 'allproducts',
      component: () => import('@/views/font/AllProducts.vue'),
      meta: { title: '全部商品' },
    },
    {
      path: '/shoppingcart',
      name: 'shoppingcart',
      component: () => import('@/views/font/ShoppingCart.vue'),
      meta: { title: '购物车' },
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/font/Login.vue'),
      meta: { title: '登录' },
    },
    {
      path: '/consultation',
      name: 'consultation',
      component: () => import('@/views/font/consultation.vue'),
      meta: { title: '文化资讯' },
    },
    {
      path: '/payment',
      name: 'payment',
      component: () => import('@/views/font/Payment.vue'),
      meta: { title: '订单支付' },
    },
    {
      path: '/notfound',
      component: () => import('@/views/404.vue'),
    },
    {
      path: '/:pathMatch(.*)*',
      redirect: '/notfound',
    },
    {
      path: '/myorders',
      name: 'myorders',
      component: () => import('@/views/font/MyOrders.vue'),
      meta: { title: '我的订单' },
    },
  ],
})

export default router
